<?php

if (version_compare(phpversion(), '5.2.4', '<') === true) {
    echo 'http://framework.zend.com/manual/1.10/en/requirements.introduction.html' . '<br />';
    die('ERROR: Your PHP version is ' . phpversion() . '. CMS requires PHP 5.2.4 or later.');
}

defined('DS') || define('DS', DIRECTORY_SEPARATOR);
defined('PS') || define('PS', PATH_SEPARATOR);

// Define base path obtainable throughout the whole application [Document Root]
defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__) . '/..'));
defined('PUBLIC_PATH') || define('PUBLIC_PATH', realpath(dirname(__FILE__)));

// Define path to application directory
defined('APP_PATH') || define('APP_PATH', realpath(BASE_PATH . DS . 'application'));

// Define path to library directory
defined('LIB_PATH') || define('LIB_PATH', realpath(BASE_PATH . DS . 'library'));

// Define path to data directory
defined('DATA_PATH') || define('DATA_PATH', realpath(BASE_PATH . DS . 'data'));

// Define application enviroment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
/**
 * Path
 */
defined('APP_LIB_PATH') || define('APP_LIB_PATH', realpath(APP_PATH . DS . 'library'));

define('ADMIN_SCRIPT_PATH', APP_PATH . '/modules/admin/views/scripts/');

// Ensure library/ is on include_path
//set_include_path(get_include_path() . PS . LIB_PATH . PS . APP_LIB_PATH);
set_include_path(implode(PS, array(get_include_path(), LIB_PATH, APP_LIB_PATH)));
// Zend Appliaction
require_once ('Zend/Application.php');

// Create Application, bootstrap and run
// Set APPLICATION_ENV in .htaccess file
$environments = array('development', 'testing', 'staging', 'production');
if (!in_array(APPLICATION_ENV, $environments)) {
    die('The application environment is not set correctly.');
}
$application = new Zend_Application(APPLICATION_ENV, realpath(APP_PATH . DS . 'configs' . DS . 'application.ini'));
$application->bootstrap();
$application->run();